const loadGoodsSaleRange = function (type = 'day', sort_key = 'pay_total', sort = 'desc') {

    $.get('admin/sale-goods-range?type=' + type + '&sort_key=' + sort_key + '&sort=' + sort, function (res) {
        $('#loading').css('display','none')
        if (res.code != 0) {
            return;
        }
        let _html = '';
        let data = res.arr;
        data.forEach((item, index) => {
            let _style ='';
            if(index<=2){
                _style='style="color:red"';
            }
            _html += '<div class="goods_content">\n' +
                '                        <div class="first_col" '+_style+'>' + (index + 1) + '</div>\n' +
                '                        <div class="second_col"><img src="' + item.discover + '" class="good_img">&nbsp;&nbsp;' + item.name + '</div>\n' +
                '                        <div class="col_goods">' + item.pay_total + '</div>\n' +
                '                        <div class="col_goods">' + item.num + '</div>\n' +
                '                        <div class="col_goods">' + item.access + '</div>\n' +
                '                        <div class="end_col">' + item.access_percent + '%</div>\n' +
                '                    </div>';
        })
        $('#goods_range_list').html(_html);
    });
}
loadGoodsSaleRange();
const loadUserBuyRange = function (type = 'day', sort_key = 'pay_total', sort = 'desc') {

    $.get('admin/user-buy-range?type=' + type + '&sort_key=' + sort_key + '&sort=' + sort, function (res) {
        $('#loading_buy').css('display','none')
        if (res.code != 0) {
            return;
        }
        let _html = '';
        let data = res.arr;
        data.forEach((item, index) => {
            let _style ='';
            if(index<=2){
                _style='style="color:red"';
            }
            _html += '<div class="goods_content">\n' +
                '                        <div class="first_col" '+_style+'>' + (index + 1) + '</div>\n' +
                '                        <div class="second_col" style="width: 30%">'+item.mobile+'</div>\n' +
                '                        <div class="col_goods" style="width: 30%">' + item.pay_total + '</div>\n' +
                '                        <div class="col_goods">' + item.num + '</div>\n' +
                '                    </div>';
        })
        $('#buy_range_list').html(_html);
    });
}
loadUserBuyRange();
